﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using WeiTap.Test.UserManager;
using WeiTap.WebApi.Test.UserManager;

namespace WeiTap.Restful.Test.Controller
{
    /// <summary>
    /// 
    /// </summary>
    public class UserController : WebApi
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public async Task<IList<User>> GetUsers()
        {
            try
            {
                throw new Exception("我的错误");
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
                throw;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public async Task AddUser(User user)
        {
            try
            {
                 await UserDa.InsertUser(user);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
                throw;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="users"></param>
        /// <returns></returns>
        public async Task Users111(IList<User> users1, IList<User> users2)
        {
            try
            {
                foreach (var u in users1)
                {
                    await UserDa.InsertUser(u);
                }
                
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
                throw;
            }
        }
        public async Task Users222(IList<User> users1)
        {
            try
            {
                foreach (var u in users1)
                {
                    await UserDa.InsertUser(u);
                }

            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
                throw;
            }
        }
    }
}
